package com.lsp.rocketmqcousumer.receiver;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 延时消息
 */
@Component
@RocketMQMessageListener(
        topic = "delayTopic",
        consumerGroup = "DELAY_CONSUME_GROUP_TEST"
)
public class DelayReceiver implements RocketMQListener<String> {

    @Override
    public void onMessage(String msg) {
        System.out.printf("Consumer 延时消费，收到消息: %s  收到时间： %s  \n",msg, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssSSS")));
    }
}
